/**
 * 
 */
package sim;

import java.awt.Shape;
import java.awt.geom.Path2D;
import java.awt.geom.Point2D.Double;

import obj.Path;

/**
 * @author peedarpk
 * 
 */
public class Car extends Vehicle {

	private java.awt.geom.Path2D.Double carShape;
	public static int CAR_WIDTH = 10;
	private static int CAR_HEIGHT = 10;

	public Car(Path path, String name) {
		this.setPath(path);
		this.setName(name);
		this.setCurrentPosition(path.getEdgesList().get(0).getStartNode().getNodePosition());
		this.setEndPosition(path.getEdgesList().get(0).getEndNode().getNodePosition());
		this.setMaxSpeed(path.getMaxSpeed());
		this.setCurrentSpeed(path.getMaxSpeed());
	}

	@Override
	void move(Double point) {
		this.setCurrentPosition(point);

	}

	@Override
	Shape getShape() {
//		 carShape = new Rectangle2D.Double(this.getX(), this.getY(),
//		 CAR_WIDTH, CAR_HEIGHT);
//		 AffineTransform transform = new AffineTransform();
//		 transform.setToIdentity();
//		 transform.rotate(2 * Math.PI + (-this.getCarAngle()),this.getX(), this.getY());
//		 transform.createTransformedShape(carShape);
//		 return transform.createTransformedShape(carShape);

		Path2D.Double pathShape = new Path2D.Double();

		pathShape.moveTo(this.getX(), this.getY());
		pathShape.lineTo(getX() + (CAR_WIDTH * Math.cos(this.getCarAngle())), getY() - (CAR_WIDTH * Math.sin(this.getCarAngle())));
		pathShape.closePath();
		carShape = pathShape;
		return carShape;
	}

}
